<template>
  <div class="app-container">
    <el-form label-width="80px" :model="qualityPredictPojo">
<!--      <h5>基本信息</h5>-->
      <el-row>
        <el-col :span="12">
          <el-form-item label="单据编号" prop="documentNumber">
            <el-input v-model="qualityPredictPojo.documentNumber" :disabled="true" maxlength="30" style="width:240px"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="用工日期" prop="predictTime">
          <el-input v-model="qualityPredictPojo.predictTime" :disabled="true" maxlength="30" style="width:240px"/>
        </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="所在岗位" prop="fillInUserPost" v-show="false">
            <el-input v-model="qualityPredictPojo.fillInUserPost" :disabled="true"  maxlength="30"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="所在部门" prop="fillInUserDept"  v-show="false">
            <el-input v-model="qualityPredictPojo.fillInUserDept" :disabled="true" maxlength="30"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="备注" prop="remark" v-show="false">
            <el-input v-model="qualityPredictPojo.remark" :disabled="true" maxlength="30"/>
          </el-form-item>
        </el-col>
      </el-row>
<!--      <h5>预测信息</h5>-->
      <el-row>
          <el-col :span="12">
            <el-form-item label="填写人员" prop="fillInName" v-show="false">
              <el-input v-model="qualityPredictPojo.fillInName" :disabled="true"  maxlength="30"/>
            </el-form-item>
          </el-col>

        <el-col :span="12">
          <el-form-item label="预测班次" prop="predictTimeShift">
            <el-input v-model="qualityPredictPojo.predictTimeShift" :disabled="true" maxlength="30" style="width:240px"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="预测24h" prop="future24PredictNumber">
            <el-input type="number" v-model="qualityPredictPojo.future24PredictNumber" maxlength="30" style="width:240px">
            <i slot="append" style="margin-right: 10px">万件</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="预测12h" prop="future12PredictNumber">
            <el-input type="number" v-model="qualityPredictPojo.future12PredictNumber" maxlength="30" style="width:240px">
              <i slot="append" style="margin-right: 10px">万件</i>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
<!--        <el-col :span="12">-->
<!--          <el-form-item label="预测量（万件）" prop="predictNumber">-->
<!--            <el-input v-model="qualityPredictPojo.predictNumber" maxlength="30"/>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
        <el-col :span="12">
          <el-form-item label="省内未发" prop="provinceNotIssued">
            <el-input type="number" v-model="qualityPredictPojo.provinceNotIssued" maxlength="30" style="width:240px">
              <i slot="append" style="margin-right: 10px">万件</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="车辆数"  prop="carNumber">
            <el-input v-model="qualityPredictPojo.carNumber" maxlength="30" @input="onInput()"  style="width:240px">
            <i slot="append" style="margin-right: 10px">辆</i>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>

        <el-col :span="12">
          <el-form-item label="待卸量" prop="unloadedNumber">
            <el-input type="number" v-model="qualityPredictPojo.unloadedNumber" maxlength="30" style="width:240px">
              <i slot="append" style="margin-right: 10px">万件</i>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="updateQualityPredict">提 交</el-button>
    </div>
  </div>
</template>

<script>
  import { viewQualityPredict , updateQualityPredict } from "@/api/job/qualityPredict/qualityPredict";
  export default {
    name: "attendanceGroup",
    created() {
      this.viewQualityPredict();
    },
    data() {
      return {

        // 是否显示弹出层（数据权限）
        openDataScope: false,
        menuExpand: false,
        menuNodeAll: false,
        deptExpand: true,
        deptNodeAll: false,
        qualityPredictId: this.$route.query.qualityPredictId,
        qualityPredictPojo:undefined,
        defaultProps: {
          children: "children",
          label: "label",
        },
      };
    },

    methods: {
      viewQualityPredict() {
        viewQualityPredict(this.qualityPredictId).then(es => {
          this.qualityPredictPojo = es.data;
        })
      },
      updateQualityPredict() {
        var future24PredictNumber = this.qualityPredictPojo.future24PredictNumber;
        var future12PredictNumber = this.qualityPredictPojo.future12PredictNumber;
        var provinceNotIssued = this.qualityPredictPojo.provinceNotIssued;
        var unloadedNumber= this.qualityPredictPojo.unloadedNumber;
        var carNumber = this.qualityPredictPojo.carNumber;
        // if ('' == String(future24PredictNumber)){
        //   alert("数据有空值");
        //   throw "";
        // }
        // if ('' == String(future12PredictNumber)){
        //   alert("数据有空值");
        //   throw "";
        // }
        // if ('' == String(provinceNotIssued)){
        //   alert("数据有空值");
        //   throw "";
        // }
        // if ('' == String(unloadedNumber)){
        //   alert("数据有空值");
        //   throw "";
        // }
        // if ('' == String(carNumber)){
        //   alert("数据有空值");
        //   throw "";
        // }


        if (future24PredictNumber ==undefined){
          alert("数据有空值");
          throw "";
        }
        if (future12PredictNumber ==undefined){
          alert("数据有空值");
          throw "";
        }
        if (provinceNotIssued ==undefined){
          alert("数据有空值");
          throw "";
        }
        if (unloadedNumber ==undefined){
          alert("数据有空值");
          throw "";
        }
        if (carNumber ==undefined){
          alert("数据有空值");
          throw "";
        }
        if (future24PredictNumber ==undefined){
          alert("数据有空值");
          throw "";
        }
        if (future12PredictNumber ==undefined){
          alert("数据有空值");
          throw "";
        }
        if (provinceNotIssued ==undefined){
          alert("数据有空值");
          throw "";
        }
        if (Number(future24PredictNumber) < 0){
          alert("数据有负数");
          throw "";
        }
        if (Number(future12PredictNumber) < 0){
          alert("数据有负数");
          throw "";
        }
        if (Number(provinceNotIssued) < 0){
          alert("数据有负数");
          throw "";
        }
        if (Number(unloadedNumber) < 0){
          alert("数据有负数");
          throw "";
        }
        if (Number(carNumber) < 0){
          alert("数据有负数");
          throw "";
        }
        if (String(carNumber).indexOf('.') != -1) {
          alert("车辆数数据有小数");
          throw "";
        }
        const data = {
          qualityPredictPojo:this.qualityPredictPojo
        }
        updateQualityPredict(data).then(es => {
          this.msgSuccess("提交成功");
          this.open = false;
        })
      },
      onInput(){
        this.$forceUpdate();
      },
    },
  };
</script>
